@extends('adminlte::page')

@section('title', '新闻发布')

@section('content_header')

@stop
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
@section('content')

    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">新闻发布中心</h3>
        </div>
        <form action="{{ route('news.update',['news'=>$news->id]) }}" method="post" id="add">
            {{ csrf_field() }}
            <div class="box-body">
                <div class="form-group">
                    <label for="exampleInputEmail1">新闻标题</label>
                    <input type="text" class="form-control" id="exampleInputEmail1" placeholder="请输入新闻标题" name="title" value="{{ $news->title }}">
                </div>

                <div class="form-group">
                    <label>选择栏目</label>
                    <select class="form-control" name="channel_id">
                        @foreach( $channels as $channel )
                            <option value="{{ $channel->id }}" {{ $channel->id== $news->channel_id ? "selected" :'' }}>{{$channel->name}}</option>
                        @endforeach
                    </select>
                </div>

                <div class="form-group">
                    <label>是否发布</label>
                    <select class="form-control" name="is_publish">
                        <option value="1" {{ $news->is_publish==1 ? "selected" :'' }}>是</option>
                        <option value="0" {{ $news->is_publish==0 ? "selected" :'' }}>否</option>
                    </select>
                </div>

                <div class="form-group">
                    <label>主图</label>
                    <span class="input-group-btn">
                        <a id="lfm" data-input="thumbnail" data-preview="holder" class="btn btn-primary">
                            <i class="fa fa-picture-o"></i> 请点击新闻主图
                        </a>
                    </span>

                    <input id="thumbnail" class="form-control" type="hidden" name="img" value="{{ $news->img }}">
                    <img id="holder" style="margin-top:15px;max-height:100px;" src="{{ $news->img }}">
                </div>

                <div class="form-group">
                    <label>文章内容</label>
                    <textarea name="content" class="textarea" id="my-editor" cols="30" rows="10">{{ $news->content }}</textarea>
                    <script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
                    <script src="/vendor/unisharp/laravel-ckeditor/adapters/jquery.js"></script>
                    <script>
                        var options = {
                            filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
                            filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token=',
                            filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
                            filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token='
                        };
                        // $('textarea').ckeditor();
                        $('.textarea').ckeditor(options); // if class is prefered.
                    </script>
                </div>

            </div>
            <!-- /.box-body -->

            <div class="box-footer">
                <button type="submit" class="btn btn-primary">提交</button>
            </div>

        </form>
        <script src="/vendor/laravel-filemanager/js/lfm.js"></script>

        <script>
            $('#lfm').filemanager('image');
        </script>
    </div>

@stop